<?php

use yii\db\Migration;

class m000000_000009_create_article_cateory extends Migration
{
    public function up()
    {
        $this->createTable('{{%article_category}}', [
            'id'=>$this->primaryKey(), // PK
            'pid'=>$this->integer(), // 上级分类编号
            'name'=>$this->string(256), // 分类名称
            'sort'=>$this->integer(), // 排序数字
        ]);
        $this->createIndex('fk_article_category_article_category1_idx', '{{%article_category}}', ['pid']);
        try {
            $this->addForeignKey('fk_article_category_article_category1', '{{%article_category}}', ['pid'], '{{%article_category}}', ['id']);
        } catch (Exception $e) {
        }
    }

    public function down()
    {
        $this->dropTable('{{%article_category}}');
    }
}
